#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int T,n,m,l,v,p[N],cnt;
struct node{
    int d,v,a;
}a[N];
struct Pair{
    int l,r;
    bool operator<(Pair b){
        return r<b.r;
    }
}b[N];
void solve(){
    cin>>n>>m>>l>>v;
    for(int i=1;i<=n;i++)
        cin>>a[i].d>>a[i].v>>a[i].a;
    for(int i=1;i<=m;i++) cin>>p[i];
    cnt=0;
    for(int i=1;i<=n;i++){
        if(a[i].v<=v&&a[i].a<=0) continue;
        if(a[i].v<=v){
            int d=a[i].d+(v*v-a[i].v*a[i].v)/(2*a[i].a);
            int x=upper_bound(p+1,p+m+1,d)-p;
            if(x<=m) b[++cnt]={x,m};
        }
        else if(a[i].a>=0){
            int x=lower_bound(p+1,p+m+1,a[i].d)-p;
            if(x<=m) b[++cnt]={x,m};
        }
        else{
            int d=a[i].d+(a[i].v*a[i].v-v*v-1)/(-2*a[i].a)+1;
            int x=lower_bound(p+1,p+m+1,a[i].d)-p;
            int y=lower_bound(p+1,p+m+1,d)-p-1;
            if(x<=y) b[++cnt]={x,y};
        }
    }
    sort(b+1,b+cnt+1);
    int las=b[1].r,ans=1;
    for(int i=2;i<=cnt;i++)
        if(b[i].l>las) ans++,las=b[i].r;
    cout<<cnt<<' '<<m-ans<<'\n';
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>T;
    while(T--) solve();
    return 0;
}
